package com.dsg.workflow;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsg.entity.apply.DsgApplyBill;
import com.dsg.entity.approve.DsgApproveCase;
import com.dsg.service.apply.IDsgApplyBillService;
import com.dsg.service.apply.IDsgApplyCarService;
import com.dsg.service.apply.IDsgApplyCusService;
import com.dsg.service.apply.IDsgApplyPayService;
import com.dsg.service.system.IDsgSysFileService;
import com.dsg.util.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * CS新申請
 */
@Slf4j
@Service
public class WorkflowService3 extends AbstractWorkflowService {

    @Autowired
    IDsgApplyCarService carService;
    @Autowired
    IDsgApplyBillService billService;
    @Autowired
    IDsgApplyPayService payService;
    @Autowired
    IDsgApplyCusService cusService;
    @Autowired
    IDsgSysFileService fileService;
    @Autowired
    WorkflowEngine engine;

    @Override
    protected String recalculateNodeName(DsgApplyBill bill) {
        if (Constant.PAY_TYPE_ATP.equals(bill.getPayType())) {
            return NODE_CHECK_CAR_NO;
        } else {
            return NODE_DEDUCT_ONE;
        }
    }

    @Override
    protected boolean canGoOn(DsgApplyBill bill) throws Exception {
        boolean pass = billService.internalAudit(bill);
        return pass;
    }

    @Override
    protected Set getConditionalNodeSet(DsgApplyBill bill) {
        Set<String> conditionalNodeSet = new HashSet<>();
        if (Constant.PAY_TYPE_ATP.equals(bill.getPayType())) {
            conditionalNodeSet.add(NODE_DDA);
            conditionalNodeSet.add(NODE_CHECK_LIST);
        } else {
            conditionalNodeSet.add(NODE_CHECK_LIST);
        }
        return conditionalNodeSet;
    }
}
